package com.ruoyi.testing.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testing.domain.EmploymentPeople;
import com.ruoyi.testing.service.IEmploymentPeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 告知书人员信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/testing/people")
public class EmploymentPeopleController extends BaseController
{
    @Autowired
    private IEmploymentPeopleService employmentPeopleService;

    /**
     * 查询告知书人员信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmploymentPeople employmentPeople)
    {
        startPage();
        List<EmploymentPeople> list = employmentPeopleService.selectEmploymentPeopleList(employmentPeople);
        return getDataTable(list);
    }

    /**
     * 导出告知书人员信息列表
     */
    @Log(title = "告知书人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmploymentPeople employmentPeople)
    {
        List<EmploymentPeople> list = employmentPeopleService.selectEmploymentPeopleList(employmentPeople);
        ExcelUtil<EmploymentPeople> util = new ExcelUtil<EmploymentPeople>(EmploymentPeople.class);
        util.exportExcel(response, list, "告知书人员信息数据");
    }

    /**
     * 获取告知书人员信息详细信息
     */
    @GetMapping(value = "/{gzsryId}")
    public AjaxResult getInfo(@PathVariable("gzsryId") Long gzsryId)
    {
        return success(employmentPeopleService.selectEmploymentPeopleByGzsryId(gzsryId));
    }

    /**
     * 新增告知书人员信息
     */
    @Log(title = "告知书人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmploymentPeople employmentPeople)
    {
        return toAjax(employmentPeopleService.insertEmploymentPeople(employmentPeople));
    }

    /**
     * 修改告知书人员信息
     */
    @Log(title = "告知书人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmploymentPeople employmentPeople)
    {
        return toAjax(employmentPeopleService.updateEmploymentPeople(employmentPeople));
    }

    /**
     * 删除告知书人员信息
     */
    @Log(title = "告知书人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gzsryIds}")
    public AjaxResult remove(@PathVariable Long[] gzsryIds)
    {
        return toAjax(employmentPeopleService.deleteEmploymentPeopleByGzsryIds(gzsryIds));
    }
}
